# Wed May 11 19:27:58 2022 edit
# 字符编码：UTF-8
# R 版本：4.2.0 alpha x64 for window 11
# cgh163email@163.com
# 个人笔记不负责任，拎了个梨🍐🍈
#.rs.restartR()
require(jsonlite)
require(rlist)
require(plyr)
rm(list = ls());gc()

dt.add <- list.load('data_all/2022年5月11日/_67__20220511173046_2058696_.json')

dfll <- do.call(rbind,lapply(dt.add, t)) |> as.data.frame()
names(dfll)
# [1] "id"        "uuid"      "county"    "town"      "name"      "address"   "ctype"     "obj"       "attr"
# [10] "status"    "ability"   "works"     "is24"      "sdate"     "stime"     "longitude" "latitude"
dt_all <- data.frame(
  id = dfll$id |>as.character() |> as.numeric()
  , county = dfll$county |> as.character()
  , name = dfll$name |> as.character()
  , address = dfll$address |> as.character()
  , ctype = dfll$ctype |> as.character()
  , obj = dfll$obj |> as.character()
  , attr = dfll$attr |> as.character()
  , status = dfll$status |> as.character()
  , sdate = dfll$sdate |> as.character()
  , stime = dfll$stime |> as.character()
  , lng = dfll$longitude |> as.character() |> as.numeric()
  , lat = dfll$latitude |> as.character() |> as.numeric()
)

write.csv(dt_all,fileEncoding = "UTF-8",
          file = 'data_all/2022年5月11日/67.csv')

#end Wed May 11 20:56:29 2022 --
#批量 Wed May 11 21:09:24 2022 ------------------------------
f.ls <- list.files(path ='data_all/2022年5月11日/',pattern = "*.json$", full.names = TRUE);length(f.ls)

dt.list <- read_json(f.ls[3])
View(dt.list)

i <- 1
dt.list <- list()
while (i< length(f.ls)) {

  dt.list[[f.ls[i]]] <-
    list.load(f.ls[i])
    # read_json(f.ls[i])
  i <- i+1
}

rm(i,f.ls)
#拆解list Wed May 11 21:20:48 2022 ------------------------------
dt.do <-
  do.call(cbind.data.frame,lapply(dt.list, t))  |>
 list.rbind()

list.select(dt.do,id) |> unlist() |> as.numeric() |>
head();rm(dt.list)

dt.dtall <-data.frame(
  id = list.select(dt.do,id) |>unlist() |>  as.numeric()
  , county = list.select(dt.do,county) |>unlist() |> as.character()
  , town = list.select(dt.do,town) |>unlist() |> as.character()
  , name = list.select(dt.do,name) |>unlist()  |> as.character()
  , address =list.select(dt.do,address) |>unlist()  |> as.character()
  , ctype = list.select(dt.do,ctype) |>unlist() |> as.character()
  , obj = list.select(dt.do,obj) |>unlist() |> as.character()
  , attr = list.select(dt.do,attr) |>unlist() |> as.character()
  , status = list.select(dt.do,status) |>unlist() |> as.character()
  , sdate = list.select(dt.do,sdate) |>unlist() |> as.character()
  , stime = list.select(dt.do,stime) |>unlist() |> as.character()
  , longitude = list.select(dt.do,longitude) |> unlist() |> as.numeric()
  , latitude = list.select(dt.do,latitude) |> unlist() |> as.numeric()
);kittyR::meowR(sound = 4)#猫叫🐱

plot(dt.dtall[1:200,12:13])
#end Wed May 11 21:38:52 2022 --
write.csv(dt.dtall,
          fileEncoding = 'UTF-8',
          file = 'data_all/2022年5月11日/ok_all_dt.csv')
#end Wed May 11 21:39:48 2022 --

